/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package BD;

import java.io.Serializable;
import java.util.Date;
import java.util.List;
import javax.persistence.*;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author ARMGARCES
 */
@Entity
@Table(name = "ordencompra_mp")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "OrdencompraMp.findAll", query = "SELECT o FROM OrdencompraMp o"),
    @NamedQuery(name = "OrdencompraMp.findByIdOrdenCompramp", query = "SELECT o FROM OrdencompraMp o WHERE o.idOrdenCompramp = :idOrdenCompramp"),
    @NamedQuery(name = "OrdencompraMp.findByFecha", query = "SELECT o FROM OrdencompraMp o WHERE o.fecha = :fecha")})
public class OrdencompraMp implements Serializable {
    @Basic(optional =     false)
    @Column(name = "fecha")
    @Temporal(TemporalType.TIMESTAMP)
    private Date fecha;
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "idOrdenCompra_mp")
    private Integer idOrdenCompramp;
    @ManyToMany(mappedBy = "ordencompraMpList")
    private List<FacturaMp> facturaMpList;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "fkidOrdenCompramp")
    private List<ItemocMp> itemocMpList;
    @JoinColumn(name = "fk_idProveedor", referencedColumnName = "idProveedor")
    @ManyToOne(optional = false)
    private Proveedor fkidProveedor;

    public OrdencompraMp() {
    }

    public OrdencompraMp(Integer idOrdenCompramp) {
        this.idOrdenCompramp = idOrdenCompramp;
    }

    public OrdencompraMp(Integer idOrdenCompramp, Date fecha) {
        this.idOrdenCompramp = idOrdenCompramp;
        this.fecha = fecha;
    }

    public Integer getIdOrdenCompramp() {
        return idOrdenCompramp;
    }

    public void setIdOrdenCompramp(Integer idOrdenCompramp) {
        this.idOrdenCompramp = idOrdenCompramp;
    }

    @XmlTransient
    public List<FacturaMp> getFacturaMpList() {
        return facturaMpList;
    }

    public void setFacturaMpList(List<FacturaMp> facturaMpList) {
        this.facturaMpList = facturaMpList;
    }

    @XmlTransient
    public List<ItemocMp> getItemocMpList() {
        return itemocMpList;
    }

    public void setItemocMpList(List<ItemocMp> itemocMpList) {
        this.itemocMpList = itemocMpList;
    }

    public Proveedor getFkidProveedor() {
        return fkidProveedor;
    }

    public void setFkidProveedor(Proveedor fkidProveedor) {
        this.fkidProveedor = fkidProveedor;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (idOrdenCompramp != null ? idOrdenCompramp.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof OrdencompraMp)) {
            return false;
        }
        OrdencompraMp other = (OrdencompraMp) object;
        if ((this.idOrdenCompramp == null && other.idOrdenCompramp != null) || (this.idOrdenCompramp != null && !this.idOrdenCompramp.equals(other.idOrdenCompramp))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "BD.OrdencompraMp[ idOrdenCompramp=" + idOrdenCompramp + " ]";
    }

    public Date getFecha() {
        return fecha;
    }

    public void setFecha(Date fecha) {
        this.fecha = fecha;
    }
    
}
